import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        double sum=0;
        double n=0;
        System.out.print("请输入一个数字:");
        Scanner scanner=new Scanner(System.in);
        n=scanner.nextDouble();
        for (int i = 1; i <=n ; i++) {//i<=n
            double ret=1.0/i;//1.0
            sum+=ret;
        }
        System.out.println(sum);
    }
    public static void main16(String[] args) {
        System.out.println("请输入要求和的阶层数:");
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int sum=0;
        for (int i = 1; i <=n ; i++) {
            int ret=1;
            for (int j = 1; j <=i ; j++) {
             ret*=j;
            }
            sum+=ret;
        }
        System.out.println(sum);
    }
    public static void main15(String[] args) {
        int sum=0;
        int i=1;
        for(i=1;i<=5;i++){
            int ret=1;
            for (int j = 1; j <=i ; j++) {
                ret*=j;
                //j++;//for循环已经有j++了
            }
            sum+=ret;
            //i++;//for循环已经有i++了-
        }
        System.out.println(sum);

    }
    public static void main14(String[] args) {
        int sum=0;

        for (int i = 1; i < 101; i++) {
            sum+=i;
        }
        System.out.println(sum);

    }
    public static void main13(String[] args) {
        int i=1;
        while (i<=7){
            if(i==3){
                i++;//哄她才能到周四，不然continue死循环，break是分手
                continue;//遇到continue，一定要有调整部分 否则会死循环

                //System.out.println("haha");//编译器会因为continue而执行不到这条代码而报错
            }
            System.out.println(i);
            i++;
        }
        for (int a = 0; a < 10; a++) {
            System.out.print(a+" ");
            System.out.print(a+" ");
        }
    }
    public static void main12(String[] args) {
        int num=100;
        while(num<200){
            if(num%3==0){
                System.out.print(num+" ");
            }
            num++;
        }
        System.out.println();
        int a=100;
        while (a<=200){
            if(a%3==0){
                System.out.println("找到了100到200中第一个3的倍数:"+a);
                break;
            }
            a++;
        }
    }

    public static void main11(String[] args) {
        int i=1;
        int sum=0;
        while(i<=5){
            int j=1;
            int ret=1;
            while(j<=i){
                ret*=j;
                j++;
            }
            sum+=ret;
            i++;
        }
        System.out.println(sum);
    }
    public static void main10(String[] args) {
        int j=1;
        int sum=0;
        while (j<=5){
            int i=1;
            int ret=1;
            while (i<=j){
                ret*=i;
                i++;
            }
            sum+=ret;
            j++;
        }
        System.out.println(sum);
    }
    public static void main9(String[] args) {
        int i=1;
        while (i<=10)
        {
            System.out.print(i+" ");
            i++;
        }
        int sum=0;
        int a=0;
        while(a<=100)
        {
            sum+=a;
            a++;
        }
        int ret=1;
        int b=1;
        while (b<=5)
        {
            ret*=b;
            b++;
        }
        System.out.println(sum);
        System.out.println(ret);
    }
    public static void main8(String[] args) {
        int x=2;
        int y=1;
        switch (x){
            case 1:
                switch (y){
                    case 1:
                        System.out.println("hehe");
                        break;
                }
                break;
            case 2:
                System.out.println("haha");
                break;
        }

    }
    public static void main7(String[] args) {
        String flg="true";
        switch (flg){
            case "true":
                System.out.println(1);
                break;
            case "false":
                System.out.println(2);
                break;
            default:
                System.out.println("haha");
                break;
        }
    }
    public static void main6(String[] args) {
//        boolean flg=true;
//        switch (flg){
//            case  true:
//                System.out.println(1);
//            case false:
//                System.out.println(2);
//            default:
//                System.out.println("haha");
//            break;
//        }
        //float,double,long,boolean这四种数据类型，不可以作为swich的参数
    }
    public static void main5(String[] args) {
        int a=1;
        switch (a){//switch里面不能是一个复杂表达式
            case 1:
                System.out.println(1);
            case 2:
                System.out.println(2);
            case 3:
                System.out.println(3);
            default:
                System.out.println("haha");
                break;
                //会一直运行到有break的地方
        }
    }
    public static void main4(String[] args) {
//        int a=10;
//        switch (a){
//            case 1:
//                System.out.println(1);
//            case 2:
//                System.out.println(2);
//            case 3:
//                System.out.println(3);
//            default:
//                System.out.println("haha");
//                break;
//        }
    }
    public static void main3(String[] args) {
        int year=2024;
        if(year%1000==0){
            if(year%400==0)
            {
                System.out.println("是闰年");
            }
        }else if(year%4==0){
            System.out.println("是闰年");
        }else {
            System.out.println("不是闰年");
        }
    }
    public static void main2(String[] args) {
        int year=2000;
        if(year%100==0){
            //判断世纪闰年
            if(year%400==0){
                System.out.println("是闰年");
            }else {
                System.out.println("不是闰年");
            }
        }else {
            //普通闰年
            if(year%4==0)
            {
                System.out.println("是闰年");
            }else {
                System.out.println("不是闰年");
            }
        }
    }
    public static void main1(String[] args) {
        int num=10;
        if(num%2==0){
            System.out.println("num是偶数");
        }else {
            System.out.println("num是奇数");
        }
    }
}
